﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cards;

namespace TexasHoldem.Hands
{
    public class FourOfAKind : HandBase
    {
        public override HandType HandType
        {
            get { return HandType.FourOfAKind; }
        }

        public Rank fourRank;

        public FourOfAKind(Card[] orderedCards)
            : base(orderedCards)
        {
            this.fourRank = orderedCards.GroupBy(card => card.Rank).First(grouping => grouping.Count() > 1).Key;
        }

        protected override int CompareByRank(HandBase other)
        {
            var onePair = other as FourOfAKind;

            int result = this.fourRank.CompareTo(onePair.fourRank);
            if (result != 0)
            {
                return result;
            }
            else
            {
                return base.CompareByRank(other);
            }
        }
    }
}